package com.PVZ.model.zombie;

import com.PVZ.engine.map.level.Level;
import com.PVZ.model.Anime;
import com.PVZ.model.Entity;
import com.PVZ.model.emuns.AnimeType;
import com.PVZ.model.emuns.Configs;
import com.PVZ.model.emuns.MoveType;
import com.PVZ.model.emuns.ZombieType;
import com.PVZ.model.plant.CherryBomb;
import com.PVZ.model.weapon.Bite;
import com.PVZ.utils.Util;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.awt.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * Created by @Author: kabuda on @Date: 2021/5/18 21:10
 */
@Getter
@Setter
@NoArgsConstructor
public abstract class Zombie extends Entity {
    private ZombieType zombieType;

    private Boolean isTransformed = false;

    public Zombie(ZombieType zombieType, Point point, int reviseX, int reviseY, int zomBieSpeed, MoveType moveType) {
        super(point, reviseX, reviseY, zomBieSpeed);
        this.zombieType = zombieType;
        this.moveType = moveType;
        this.setWeapon(new Bite(Configs.demages.get(zombieType)));
    }

    @Override
    public void setAnime() {

    }

    public Zombie(ZombieType zombieType) {
        this.zombieType = zombieType;
        this.setWeapon(new Bite());
    }

    public Zombie(ZombieType zombieType, int row, int col, int reviseX, int reviseY, int zomBieSpeed) {
        super(row, col, reviseX, reviseY, zomBieSpeed);
        this.zombieType = zombieType;
        this.setWeapon(new Bite(Configs.demages.get(this.zombieType)));
    }

    public void startEat(){
        stopMove();

        setCurAnimeType(AnimeType.ATTACK);
    }

    public void startMove(){
        setCurSpeed(getSpeed());
        setCurAnimeType(AnimeType.MOVE);

    }

    /**
     * @return 普通僵尸移动
     */
    public Anime getNormalZombie() {
        String src = "res/img/zombiePng/NormalZombie/move";

        int starIndex = 0;
        int endIndex = 30;

        return Util.createAnime(src, "Move", starIndex, endIndex, -1);
    }

    /**
     * @return 普通僵尸死亡
     */
    public Anime getNormalZombieDeid() {
        String src = "res/img/zombiePng/NormalZombie/ZombieDie";

        int starIndex = 0;
        int endIndex = 9;

        return Util.createAnime(src, "ZombieDie", starIndex, endIndex, 1);
    }

    /**
     * @return 僵尸被炸死
     */
    public Anime getBoomKill() {
        String src = "res/img/zombiePng/NormalZombie/died";

        int starIndex = 3;
        int endIndex = 40;

        return Util.createAnime(src, "Died", starIndex, endIndex, 1);
    }

    public void boomed(){
        Map<AnimeType, Anime> animeMap = getAnimeMap();
        //修改死亡动画
        animeMap.put(AnimeType.BREAK,getBoomKill());

        setHealth(-1);
        setSpeed(0);

    }
}
